using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using TMPro;
using TowerDefence_Zombie.Data;

namespace TowerDefence_Zombie
{
    public class ItemSynthesis : MonoBehaviour
    {
        [SerializeField] private CanvasGroup canvasGroup;
        [SerializeField] private Image towerIcon;
        [SerializeField] private TMP_Text towerLvText;

        private bool _activityState;

        private void Awake()
        {
            canvasGroup.blocksRaycasts = false;
            canvasGroup.alpha = 0;
            _activityState = false;
        }

        public void RefreshTowerInfo(int towerId, int level)
        {
            if (towerId > 0)
            {
                var drDataTower = GameEntry.Data.GetData<DataTower>();
                var itemTowerData = drDataTower.GetTowerData(towerId);

                towerIcon.sprite = Resources.Load<Sprite>(itemTowerData.Icon);
                towerLvText.text = $"lv {level + 1}";
            }
        }

        public void SetActivityState(bool state)
        {
            if (_activityState == state) return;

            if (state) canvasGroup.alpha = 1;
            else canvasGroup.alpha = 0;

            _activityState = state;
        }
    }
}
